package cn.stylefeng.guns.modular.level.util;

import cn.stylefeng.guns.modular.level.entity.Level;

import java.util.List;

/**
 * ┌─┐       ┌─┐ + +
 * ┌──┘ ┴───────┘ ┴──┐++
 * │                 │
 * │       ───       │++ + + +
 * ███████───███████ │+
 * │                 │+
 * │       ─┴─       │
 * │                 │
 * └───┐         ┌───┘
 * │         │
 * │         │   + +
 * │         │
 * │         └──────────────┐
 * │                        │
 * │                        ├─┐
 * │                        ┌─┘
 * │                        │
 * └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 * │ ─┤ ─┤       │ ─┤ ─┤
 * └──┴──┘       └──┴──┘  + + + +
 * 神兽保佑
 * 代码无BUG!
 */

public class ListUtil {
    public static List<Level> gradeList(List<Level> levelList){
        int levelA = (int)(levelList.size()*0.3);
        Level level1 = levelList.get(levelA-1);
        Level level2 = levelList.get(levelA);
        if(level1.getScore() == level2.getScore()){
            for (Level level : levelList) {
                if(level.getScore() > level1.getScore() && level.getScore()>= 80){
                    level.setGrade("A");
                }else if ( (level.getScore() <= level1.getScore())&&level.getScore()>=80 ){
                    level.setGrade("B");
                }else if (level.getScore() < 80){
                    level.setGrade("C");
                }
            }
        }else{
            for (Level level : levelList) {
                if(level.getScore() >= level1.getScore() && level.getScore()>= 80){
                    level.setGrade("A");
                }else if ( (level.getScore() < level1.getScore())&&level.getScore()>=80 ){
                    level.setGrade("B");
                }else if (level.getScore() < 80){
                    level.setGrade("C");
                }
            }
        }
        return levelList;
    }
}
